#include <iostream>
#include <climits>

using namespace std;

/**
 * https://www.luogu.com.cn/problem/P1909
 */
int main(){
    int n;
    cin >> n;

    int money = INT_MAX;
    for(int i = 0; i < 3; i++){
        int num, price;
        cin >> num >> price;

        if (n % num == 0){
            int total = n / num * price;
            if (total < money){
                money = total;
            }
        }else{
            int total = (n / num+1) * price;
            if (total < money){
                money = total;
            }
        }
    }

    cout << money;



    return 0;
}